package com.workflow.server.utils;

import com.workflow.server.enums.ReturnCode;
import lombok.Data;

/**
 * @author : ForeverKobe
 */
@Data
public class Response<T> {
    private int status;
    private String message;
    private T data;
    private long timestamp;

    public Response() {
        this.timestamp = System.currentTimeMillis();
    }

    public static <T> Response<T> success(T data) {
        Response<T> resultData = new Response<>();
        resultData.setStatus(ReturnCode.RC100.getCode());
        resultData.setMessage(ReturnCode.RC100.getMessage());
        resultData.setData(data);
        return resultData;
    }

    public static <T> Response<T> fail(int code, String message) {
        Response<T> resultData = new Response<>();
        resultData.setStatus(code);
        resultData.setMessage(message);
        return resultData;
    }
}

